package day14.Volatile;

public class Lian02 {
    public static void main(String[] args) {
        ice a = new ice();
        for (int i = 0; i < 100; i++) {
            new Thread(a).start();
        }
    }
}

class ice implements Runnable {
    private volatile int count = 0;
    private Object lock = new Object();

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            synchronized (lock) {
                count++;
                System.out.println("已经送了" + count + "个冰淇淋");
            }
        }
    }
}
